// Copyright (c) 2007 Robin Boerdijk. All rights reserved.
//
// This software is licensed under the terms of the Microsoft Reciprocal License as described 
// in the file LICENSE.txt, which you should have received as part of this distribution. The 
// license terms are also available at http://www.opensource.org/licenses/ms-rl.html.

#include "wtkpc.h"

#include "wtk/Geometry.h"

namespace wtk
{
	POINT GetDefaultWindowPosition(const SIZE &windowSize, const RECT &containerRect)
	{
		SIZE containerSize = Construct<SIZE>(containerRect);
		POINT defaultWindowPosition;
		defaultWindowPosition.x = containerRect.left + (containerSize.cx - windowSize.cx) / 2;
		defaultWindowPosition.y = containerRect.top + (containerSize.cy - windowSize.cy) / 2;
		if (defaultWindowPosition.x < 0) {
			defaultWindowPosition.x = 0;
		}
		if (defaultWindowPosition.y < 0) {
			defaultWindowPosition.y = 0;
		}
		return defaultWindowPosition;
	}
}